package com.efast.dmom.aps.entity.base;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

/**
 * 
 * @author WilliamWu
 *
 */

public class BaseEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	// id 主键
	// description 描述,可以记录操作说明
	// site_id 平台代码，用于多平台实例整合
	// creation_time 创建时间
	// creation_time_zone 创建时间的时区
	// creator 创建用户
	// last_modified_time 最后修改时间
	// last_modified_time_zone 最后修改时间的时区
	// last_modifier 最后修改用户
	// creation_pid 创建的PID
	// last_modified_pid 最后更新的PID
	// row_status 行状态 1保留2失效、隐藏3待删除（起删除服务后会删除）
	// row_trx_id 行的操作日志id

	private long id;
	// Aaron: add name property for base entity object
	private String name;
	private String description;
	private int siteId;
	// Aaron: change from LocalDate to LocalDateTime
	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime creationTime;
	
	private String creationTimeZone;
	
	private String creator;
	
	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
	private LocalDateTime lastModifiedTime;
	
	private String lastModifiedTimeZone;
	private String lastModifier;
	private int creationPid;
	private int lastModifiedPid;
	private int rowStatus;
	private long rowTrxId;

	private short modificationFlag;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getSiteId() {
		return siteId;
	}

	public void setSiteId(int siteId) {
		this.siteId = siteId;
	}

	public LocalDateTime getCreationTime() {
		return creationTime;
	}

	public void setCreationTime(LocalDateTime creationTime) {
		this.creationTime = creationTime;
	}

	public String getCreationTimeZone() {
		return creationTimeZone;
	}

	public void setCreationTimeZone(String creationTimeZone) {
		this.creationTimeZone = creationTimeZone;
	}

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public LocalDateTime getLastModifiedTime() {
		return lastModifiedTime;
	}

	public void setLastModifiedTime(LocalDateTime lastModifiedTime) {
		this.lastModifiedTime = lastModifiedTime;
	}

	public String getLastModifiedTimeZone() {
		return lastModifiedTimeZone;
	}

	public void setLastModifiedTimeZone(String lastModifiedTimeZone) {
		this.lastModifiedTimeZone = lastModifiedTimeZone;
	}

	public String getLastModifier() {
		return lastModifier;
	}

	public void setLastModifier(String lastModifier) {
		this.lastModifier = lastModifier;
	}

	public int getCreationPid() {
		return creationPid;
	}

	public void setCreationPid(int creationPid) {
		this.creationPid = creationPid;
	}

	public int getLastModifiedPid() {
		return lastModifiedPid;
	}

	public void setLastModifiedPid(int lastModifiedPid) {
		this.lastModifiedPid = lastModifiedPid;
	}

	public int getRowStatus() {
		return rowStatus;
	}

	public void setRowStatus(int rowStatus) {
		this.rowStatus = rowStatus;
	}

	public long getRowTrxId() {
		return rowTrxId;
	}

	public void setRowTrxId(long rowTrxId) {
		this.rowTrxId = rowTrxId;
	}

	public short getModificationFlag() {
		return modificationFlag;
	}

	public void setModificationFlag(short modificationFlag) {
		this.modificationFlag = modificationFlag;
	}

	public boolean equals(BaseEntity obj) {

		boolean result = false;

		if (obj == null) {
			return result;
		}

		if (getId() <= 0) {
			result = (this == obj);
		} else {
			result = (this.getId() == obj.getId());
		}

		return result;
	}

}
